package handler

import (
	"fmt"
	"gomicro/httpJsonMicro/hjmServer/service"
	"gomicro/httpJsonMicro/model"
	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/mvc"
	"encoding/json"
)

//会员套餐信息服务管理实现
type MemberHandlerCuda struct {
	Ctx  iris.Context
	Mip *service.MemberSriImp
	Tag string
}

func (c *MemberHandlerCuda) PostInsertall() mvc.Result {

	var reqinfo map[string]string
	var mm []*model.Member

	err := c.Ctx.ReadJSON(&reqinfo)
	if err != nil{
		return mvc.Response{
			Object : err,
		}
	}
	if uerr := json.Unmarshal([]byte(reqinfo["info"]), &mm); uerr == nil{

		var t = service.MemberSriImp{}
		c.Mip = &t

		res := c.Mip.InesrtSri(mm)
		return mvc.Response{
        	Object : res,
    	}
	}else{
		return mvc.Response{
			Object : map[string]string{
				"message":"解析失败",
				"code":"400",
			},
		}
	}
}

func (c *MemberHandlerCuda) PostQueryallinfo() mvc.Result {
	fmt.Println("被请求了。。。。。。。")
	var t = service.MemberSriImp{}
	c.Mip = &t

	res := c.Mip.QuerySri()
	return mvc.Response{
		Object : res,
	}
}

